package com.bowen.controller;

import com.bowen.service.UidGenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * create zt 2022-03-31
 */
@RestController
public class UidController {

    @Autowired
    private UidGenService uidGenService;


    /**
     * 实时生成
     * @return
     */
    @GetMapping("/uidGenerator")
    public String UidGenerator() {
        return String.valueOf(uidGenService.getUid());
    }



    /**
     * 基于redis
     * @return
     */
    @GetMapping("/getUidByRedis")
    public String getUidByRedis() {
        return  uidGenService.getUidByRedis();
    }


    /**
     * 基于本地缓存生成
     * @return
     */
    @GetMapping("/getUidByLocal")
    public Long getUidByLocal() {
        return  uidGenService.getUidByLocal();
    }

}
